//
//  MyEmotion.m
//  WeChat
//
//  Created by ibokan on 16/2/20.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "YJEmotion.h"
#import "MJExtension.h"
@implementation YJEmotion
//归档
MJCodingImplementation

//对象内存地址比较方法(每个对象都有这个方法) [array remove:object]是根据内存地址进行删除的,会调用该方法

//比较的是地址指针(重写该方法，从而能利用[array remove:object]进行删除)
-(BOOL)isEqual:(YJEmotion *)emotion //(与 == 作用一样)
{
    //自定义表情，emoji表情
    return ([emotion.chs isEqualToString:self.chs]|| [emotion.code isEqualToString:self.code]);
    
}

-(instancetype)initWithDict:(NSDictionary *)dict
{
    self = [super init];
    if (self)
    {
        self.chs = dict[@"chs"];
        self.png = dict[@"png"];
        self.code = dict[@"code"];
        self.type = dict[@"type"];
    }
    return self;
}

+(instancetype)emotionWithDict:(NSDictionary *)dict
{
    return [[self alloc]initWithDict:dict];
}

+(NSArray *)emotionsWith:(NSArray *)array
{
    
    NSMutableArray *arrayM = [[NSMutableArray alloc]init];
    for (NSDictionary *dict in array)
    {
        [arrayM addObject:[self emotionWithDict:dict]];
    }
    return arrayM;
}
@end
